package com.example.redistest.ThreadDemo;

public class ThreadDemo1 extends Thread {
    private String name;
    public ThreadDemo1(String name){
        this.name = name;
    }

    @Override
    public void run() {
        for (int i=0; i<100; i++){
            System.out.println(name + "运行"+i);
        }
        try {
            sleep((int) Math.random() * 10);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        ThreadDemo1 thread1 =  new ThreadDemo1("A");
        ThreadDemo1 thread2 = new ThreadDemo1("B");
        thread1.start();
        thread2.start();
    }

}
